package net.pws.oos.biz.service;

import org.apache.commons.tfs.Licence;
import org.apache.commons.tfs.LicenceFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Service;

@Service
public class LicenceService implements BeanPostProcessor {

	public Object postProcessAfterInitialization(Object arg0, String arg1)
			throws BeansException {
		Licence licence = LicenceFactory.getInstance().getLicence();
		if (!licence.validate()) {
			throw new FatalBeanException(licence.getErrorMessage());
		}
		return arg0;
	}

	public Object postProcessBeforeInitialization(Object arg0, String arg1)
			throws BeansException {
		return arg0;
	}

}
